<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>BEST-知客招生系统页面</title>
		<!--引入global.js： 公共文件的引入、关于token-->
		<script src="js/global.js"></script>
		<script src="js/loginFilter.js"></script>
		<!--登录验证，未登录的话，就自动跳转到登录页-->
		<style>
			/*样式设置*/
			
			body {
				margin: 0;
			}
			
			#scroll-box {
				width: 800px;
				height: 26px;
				/*background: black;*/
				margin-left: 570px;
				overflow: hidden;
			}
			
			#scroll-box ul {
				margin: 0
			}
			
			#scroll-box li {
				color: white;
				font-size: 20px;
			}
			
			#img {
				width: 25px;
				height: 15px;
				position: absolute;
				right: 80px;
				margin-top: 12px;
				top: 1px;
				text-align: center;
			}
			
			#img1 {
				width: 25px;
				height: 15px;
				position: absolute;
				right: 80px;
				margin-top: 12px;
				top: 1px;
				text-align: center;
			}
			
			#img2 {
				width: 25px;
				height: 15px;
				position: absolute;
				right: 80px;
				margin-top: 12px;
				top: 1px;
				text-align: center;
			}
		</style>
	</head>

	<body class="layui-layout-body">
		<div class="layui-layout layui-layout-admin">
			<div class="layui-header" id="color">
				<div class="layui-logo">BEST-知客招生系统</div>
				<!-- 头部区域（可配合layui已有的水平导航） -->
				<ul class="layui-nav layui-layout-left">
					<li class="layui-nav-item">
						<a href="index.html">首页</a>
					</li>
					<!-- <li class="layui-nav-item"><a href="">控制台</a></li>
				<li class="layui-nav-item"><a href="">商品管理</a></li> -->
					<li class="layui-nav-item">
						<a href="chat.html" target="right">聊天室</a>
					</li>
					<li id="allstatus" class="layui-nav-item">
						<a id="infostatus" target="right">消息动态<span class="layui-badge" id="infosize">0</span></a>
					</li>
					<li class="layui-nav-item">
						<a id="advicestatus" target="right">所有公告<span class="layui-badge" id="advicesize">0</span></a>
					</li>
					<!-- <li class="layui-nav-item"><a href="javascript:;">其它系统</a>
					<dl class="layui-nav-child">
						<dd>
							<a href="">邮件管理</a>
						</dd>
						<dd>
							<a href="">消息管理</a>
						</dd>
						<dd>
							<a href="">授权管理</a>
						</dd>
					</dl></li> -->
				</ul>
				<!--公告-->
				<div id="scroll-box" layui-bg-black>
					<ul id="addadvicegun">
					</ul>
					<ul></ul>
				</div>

				<ul class="layui-nav layui-layout-right">
					<li class="layui-nav-item">
						<a id="openHeadImg" title="修改头像" data-options="menu:'#mm1'">
							<img src="" id="userimg" class="layui-nav-img">
								<span id="showLoginName">贤心</span>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a id="updateu">修改头像</a>
							</dd>
							<dd>
								<a href="time.html" target="right">闹钟天气</a>
							</dd>
							<dd>
								<a href="javascript:;" onclick="lockScreen()">锁定屏幕</a>
							</dd>
							<dd>
								<a href="javascript:;" id="xiugaipswBtn">修改密码</a>
							</dd>
							<dd>
								<a href="javascript:;" id="qiandaoBtn">签到</a>
							</dd>
							<dd>
								<a href="javascript:;" id="qiantuiBtn">签退</a>
							</dd>
							<dd>
								<a href="javascript:;" id="qingjiaBtn">员工请假</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a><span class="layui-icon" style="font-size:14px;">&#xe66a;  </span>主题</a>
						<dl class="layui-nav-child">
							<dd>
								<a class="layui-icon layui-bg-red" style="font-size:13px;" onclick="designThems()">&#xe617; red</a>
							</dd>
							<dd>
								<a class="layui-icon layui-bg-orange" style="font-size:13px;" onclick="designThems1()">&#xe617; orange</a>
							</dd>
							<dd>
								<a class="layui-icon layui-bg-green" style="font-size:13px;" onclick="designThems2()">&#xe617; green</a>
							</dd>
							<dd>
								<a class="layui-icon layui-bg-blue" style="font-size:13px;" onclick="designThems4()">&#xe617; blue</a>
							</dd>
							<dd>
								<a class="layui-icon layui-bg-black" style="font-size:13px;" onclick="designThems5()">&#xe617; black</a>
								<dd>
								</dd>
								<a class="layui-icon layui-bg-gray" style="font-size:13px;" onclick="designThems6()">&#xe617; gray</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="welcome.html" target="right" id="logoutLink">退出</a>
					</li>
				</ul>
			</div>

			<div class="layui-side layui-bg-black">
				<div class="layui-side-scroll">
					<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
					<ul class="layui-nav layui-nav-tree" lay-filter="test" id="mynav">
						<!-- <li class="layui-nav-item layui-nav-itemed"><a class="" -->
						<!--<li class="layui-nav-item"><a class=""
						href="javascript:;">基础管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="student.html" target="right">学生管理</a>
							</dd>
							<dd>
								<a href="teacher.html" target="right">教师管理</a>
							</dd>
							<dd>
								<a href="membership.html" target="right">院系管理</a>
							</dd>
							
						</dl></li>
					<li class="layui-nav-item"><a href="javascript:;">高级管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="dailylog.html" target="right">日志管理</a>
							</dd>
							<dd>
								<a href="statistic2.html" target="right">资源统计折线图</a>
							</dd>
							
						</dl></li>
					<li class="layui-nav-item"><a href="showcard.html" target="right">模拟刷卡</a></li>
				    <li class="layui-nav-item"><a href="chat.html" target="right">交流中心</a></li>-->
					</ul>
				</div>
			</div>
			<div class="layui-body">
				<!-- 内容主体区域 -->
				<div style="padding: 10px;">
					<iframe frameborder="0" style="width: 100%; min-height:700px;height:100%" src="welcome.html" name="right"> 
					</iframe>
				</div>

			</div>

			<div class="layui-footer">
				<!-- 底部固定区域 -->
				BEST-知客招生系统
			</div>
		</div>

		<!-- 修改密码弹窗 -->
		<form id="formEdit" style="margin-top:20px;display: none;" onsubmit="return false;" class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">原密码:</label>
				<div class="layui-input-block">
					<input id="oldPsw" type="password" name="oldPsw" autocomplete="off" class="layui-input" lay-verify="required" style="width: 180px;">
					<img id="img" onclick="hideShowPsw()" src="img/20200328004805547.png">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码:</label>
				<div class="layui-input-block">
					<input id="newPsw" type="password" name="password" autocomplete="off" class="layui-input" lay-verify="required" style="width: 180px;">
					<img id="img1" onclick="hideShowPsw1()" src="img/20200328004805547.png">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认新密码:</label>
				<div class="layui-input-block">
					<input id="newPswAgain" type="password" autocomplete="off" class="layui-input" lay-verify="required" style="width: 180px;">
					<img id="img2" onclick="hideShowPsw2()" src="img/20200328004805547.png">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="editPsw"><i class="layui-icon">&#xe605;</i>保存</button>
					<button type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon">&#x1006;</i>重置</button>
				</div>
			</div>
		</form>
		<!-- 修改密码弹窗结束 -->

		<!--员工请假弹窗 -->
		<form id="qingjaiform" style="margin-top:20px;display: none;" onsubmit="return false;" class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">请假人</label>
				<div class="layui-input-inline">
					<h3 id="user_name">a</h3>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">请假原因</label>
				<div class="layui-input-inline">
					<input type="text" name="reason" placeholder="请输入请假原因" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">请假开始时间</label>
				<div class="layui-input-inline">
					<input type="text" name="startTime" id="startTime" placeholder="请输入请假开始时间" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">请假结束时间</label>
				<div class="layui-input-inline">
					<input type="text" name="endTime" id="endTime" placeholder="请输入请假结束时间" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">备注</label>
				<div class="layui-input-inline">
					<input type="text" name="remark" placeholder="请输入备注信息" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="qingjia"><i class="layui-icon">&#xe605;</i>请假</button>
					<button type="reset" class="layui-btn layui-btn-primary"><i class="layui-icon">&#x1006;</i>重置</button>
				</div>
			</div>
		</form>
		<!-- 员工请假弹窗结束 -->

		<!--修改头像-->
		<div class="avatar" id="xiugaiimg" style="display: none">
			<form class="layui-form" onsubmit="return false">
				<div class="layui-form-item">
					<label class="layui-form-label">头像</label>
					<div class="layui-input-inline">
						<!-- 点击上传的容器 -->
						<input type="file" name="pictureFile" id="pictureFileUpdate" placeholder="请选择" autocomplete="off" class="layui-input">
						<input type="hidden" name="userImgurl" id="imgUrlUpdate">
						<!-- 隐藏域，提交表单时拥有图片的值  -->
						<img src="" id="imgShowUpdate" style="width: 150px;height: 150px;" />

						<!-- 展示图片用的 -->
						<input type="hidden" name="id" id="userid" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" id="subImgBtn">立即提交</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>

		<script>
			/*锁定屏幕*/
			function lockScreen() {
				window.location.href = "http://127.0.0.1:8020/springboot-crm-manage-mp/lockScreen.html";
				globalData.setUserInfo(null, globalData.getCurUName());
			}
		</script>

		<script>
			/*密码明文暗文*/
			//隐藏text block，显示password block
			var demoImg = document.getElementById("img");
			var demoImg1 = document.getElementById("img1");
			var demoImg2 = document.getElementById("img2");

			var PWD = document.getElementById("oldPsw");
			var PWD1 = document.getElementById("newPsw");
			var PWD2 = document.getElementById("newPswAgain");

			function hideShowPsw() {
				if(PWD.type == "password") {
					PWD.type = "text";
					demoImg.src = "img/20200328004721243.png"; //图片路径（闭眼图片）
				} else {
					PWD.type = "password";
					demoImg.src = "img/20200328004805547.png"; //图片路径（睁眼图片）
				}
			}

			function hideShowPsw1() {
				if(PWD1.type == "password") {
					PWD1.type = "text";
					demoImg1.src = "img/20200328004721243.png"; //图片路径（闭眼图片）
				} else {
					PWD1.type = "password";
					demoImg1.src = "img/20200328004805547.png"; //图片路径（睁眼图片）
				}
			}

			function hideShowPsw2() {
				if(PWD2.type == "password") {
					PWD2.type = "text";
					demoImg2.src = "img/20200328004721243.png"; //图片路径（闭眼图片）
				} else {
					PWD2.type = "password";
					demoImg2.src = "img/20200328004805547.png"; //图片路径（睁眼图片）
				}
			}
		</script>

		<!-- 照片弹窗 -->
		<div id="SetHeadImg" style="display: none;" data-options="modal:true,closed:true,iconCls:'icon-save'" style="top:217;width:492px;height:300px;padding:10px;">
			<div>
				<img id="touImg" style="position:absolute;top:40px;left:23px;width: 220px;height: 200px;" src="img/touxiang.jpg" />
				<video id="video" style="display:none;position:absolute;top:40px;left:265px; width: 200px;height: 150px;"></video>
				<canvas id="canvas" style="display:none;position:absolute;top:40px;left:490px; width:200px; height:200px;"></canvas>
				<div style="position:absolute;top:243px;left:92px;">
					<a href="javascript:void(0)" class="layui-btn" type="button" data-options="iconCls:'icon-camera'" onclick="paizhao()"><h2>拍照上传</h2></a>
					<button id="capture" class="layui-btn" style="display:none;position:relative;top:3px;left:80px;">拍照</button>
					<button id="capture1" class="layui-btn"onclick="submitPaiZhao()" style="display:none;position:relative;top:3px;left:90px;">确定</button>
				</div>
			</div>
		</div>
		<!-- 照片弹窗结束 -->

		<script>
			var pho;
			layui.use(['layer', 'form'], function() {
				$ = layui.$;
				var layer = layui.layer;
				var form = layui.form;
				$("#touImg").attr("src", globalData.getuserUrl());
				//点击头像
				$("#openHeadImg").click(function() {
					pho = layer.open({
						type: 1,
						title: '拍照上传',
						content: $("#SetHeadImg"),
						area: ['500px', '380px']
					});
				});
			});
			//点击拍照上传按钮
			function paizhao() {

				if(navigator.mediaDevices.getUserMedia || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia) {
					//调用用户媒体设备, 访问摄像头
					getUserMedia({
						video: {
							width: 400,
							height: 500
						}
					}, success, error);
					$("#video").show();
					$("#capture").show();
					$("#capture1").show();
				} else {
					alert('不支持访问用户媒体');
				}
			}
			//访问用户媒体设备的兼容方法
			function getUserMedia(constraints, success, error) {
				if(navigator.mediaDevices.getUserMedia) {
					//最新的标准API
					navigator.mediaDevices.getUserMedia(constraints).then(success).catch(error);
				} else if(navigator.webkitGetUserMedia) {
					//webkit核心浏览器
					navigator.webkitGetUserMedia(constraints, success, error)
				} else if(navigator.mozGetUserMedia) {
					//firfox浏览器
					navigator.mozGetUserMedia(constraints, success, error);
				} else if(navigator.getUserMedia) {
					//旧版API
					navigator.getUserMedia(constraints, success, error);
				}
			}

			let video = document.getElementById('video');
			let canvas = document.getElementById('canvas');
			let context = canvas.getContext('2d');

			function success(stream) {
				//兼容webkit核心浏览器
				let CompatibleURL = window.URL || window.webkitURL;
				//将视频流设置为video元素的源
				console.log(stream);

				//video.src = CompatibleURL.createObjectURL(stream);
				video.srcObject = stream;
				video.play();
			}

			function error(error) {
				console.log(`访问用户媒体设备失败${error.name}, ${error.message}`);
			}

			document.getElementById('capture').addEventListener('click', function() {
				context.drawImage(video, 0, 0, 250, 100);
				var imgData = canvas.toDataURL(); //获取图片的base64格式的数据
				console.log(imgData)
				$("#touImg").attr("src", imgData);

			})

			function submitPaiZhao() {
				$.ajax({
					type: 'POST',
					url: globalData.server + "user/uploadHeadImg",
					data: {
						"photo": $("#touImg").attr("src"),
						"token": globalData.getToken(),
						"userId": globalData.getCurUid()
					},
					success: function(res) {
						//$("#userimg").attr("src", res.data);
						console.log(res.message);
						globalData.setuserUrl(res.message);
						window.location.reload();
					}
				});

			}
		</script>

		<script>
			//主题设置
			function designThems() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-red");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-red x-side");
			}

			function designThems1() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-orange");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-orange x-side");
			}

			function designThems2() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-green");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-green x-side");
			}

			function designThems4() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-blue");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-blue x-side");
			}

			function designThems5() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-black");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-black x-side");
			}

			function designThems6() {
				var div = document.getElementById('color');
				div.setAttribute("class", "layui-header header header-demo layui-bg-gray");
				var div1 = document.getElementById('col');
				div1.setAttribute("class", "layui-side layui-bg-gray x-side");
			}
			//主题设置--end

			//JavaScript代码区域
			layui.use(['element', 'layer', 'form', 'laydate', 'upload'], function() {
				var element = layui.element;
				var layer = layui.layer;
				var $ = layui.$;
				var form = layui.form;
				var laydate = layui.laydate;
				var upload = layui.upload;

				//执行一个laydate实例
				laydate.render({
					elem: '#startTime', //指定元素
					type: 'datetime'
				});
				laydate.render({
					elem: '#endTime', //指定元素
					type: 'datetime'
				});

				//设置显示登录用户名
				$("#showLoginName").html(globalData.getCurUName());

				//回显请假人姓名
				$(function() {
					$("#user_name").text(globalData.getCurUName());
				})

				//渲染左侧的导航
				$.post(globalData.server + "module/getModuleTreeByUserId", {
					"uid": globalData.getCurUid(),
					"token": globalData.getToken()
				}, function(res) {
					console.log(res)
					if(res != null) {
						$("#mynav").html("");
						for(var i = 0; i < res.length; i++) { //遍历父节点
							var str = '<li class="layui-nav-item"><a href="javascript:;">' + res[i].title + '</a><dl class="layui-nav-child">'
							for(var j = 0; res[i].children != null && j < res[i].children.length; j++) {
								str += '<dd><a href="' + res[i].children[j].path + '"target="right">' + res[i].children[j].title + '</a></dd>'
							}
							str += '</dl></li>'
							$("#mynav").append(str);
						}
						//$("#mynav").html(str);
						element.render('nav'); //重新对导航进行渲染
					}
				}) //渲染--end

				//退出
				$("#logoutLink").click(function() {
					layer.confirm('您确定要退出吗?', {
						icon: 3,
						title: '您正在退出此系统'
					}, function(index) {
						globalData.setUserInfo(null, null); //清空浏览器存储的用户信息
						globalData.setToken(null); //清空浏览器存储的tokenId
						window.location.href = 'login.html';
						layer.close(index);
					});
				}) //退出--end

				//签到
				$("#qiandaoBtn").click(function() {
					$.post(globalData.server + "user/qianDao", {
						"id": globalData.getCurUid(),
						"token": globalData.getToken()
					}, function(res) {
						layer.msg(res.msg, {
							icon: 1,
							time: 2000
						}, function() {
							layer.closeAll();
						});
					});
				}) //签到--end

				//签退
				$("#qiantuiBtn").click(function() {
					$.post(globalData.server + "user/qianTui", {
						"id": globalData.getCurUid(),
						"token": globalData.getToken()
					}, function(res) {
						layer.msg(res.msg, {
							icon: 1,
							time: 2000
						}, function() {
							layer.closeAll();
						});
					});
				}) //签退--end

				//修改密码弹窗
				$("#xiugaipswBtn").click(function() {
					layer.open({
						type: 1,
						content: $('#formEdit'),
						title: "修改密码",
						area: ['400px', '300px']
					})
				}) //修改密码弹窗--end

				//员工请假弹窗
				$("#qingjiaBtn").click(function() {
					layer.open({
						type: 1,
						content: $('#qingjaiform'),
						title: "员工请假",
						area: ['450px', '500px']
					})
				}) //员工请假弹窗--end

				//消息动态
				var acitve = {
					getXiaoXiInfo: function() {
						//-----begin
						$.post(globalData.server + "message/getMessages?token=" + globalData.getToken(), {
							id: globalData.getCurUid()
						}, function(res) {
							if(res.code == 0) {
								var num = 0;
								for(var i = 0; i < res.data.length; i++) {
									if(res.data[i].isOpen == "未打开") {
										num += 1;
									}
								}
								if(num == 0) {
									$('#infosize').hide();
								} else {
									$('#infosize').html(num);

								}

								$("#infostatus").click(function() {
									layer.open({
										type: 2,
										title: '消息动态',
										area: ['530px', '500px'],
										content: 'message.html'
									})
								})
							} else {
								var num = 0;
								if(num == 0) {
									$('#infosize').hide();
								} else {
									$('#infosize').html(num);

								}
							}
						})

						//----end
					}
				}

				//消息动态--end

				//公告动态
				$.post(globalData.server + "notice/getNotice?token=" + globalData.getToken(), function(res) {
					if(res.length <= 0) {
						$('#advicesize').hide();
					} else {
						$("#addadvicegun").html("");
						for(var i = 0; i < res.length; i++) { //遍历父节点
							var str = '<li class="layui-nav-item">' + "公告内容:【" + res[i].content + "】，发布时间:" + res[i].createTime + '</li>'
							$("#addadvicegun").append(str);
						}
						element.render('addadvicegun'); //重新对导航进行渲染。

						var box = document.getElementById('scroll-box')
						var parent = document.getElementsByTagName('ul')[1]
						var parent2 = document.getElementsByTagName('ul')[2]
						parent2.innerHTML = parent.innerHTML
						/*启动定时器*/
						var timer = setInterval(autoScrollLine, 30)
						/*单行向上滚动效果*/
						function autoScrollLine() {
							/*判断滚动内容是否已经滚完，滚完了则滚动的值重新设置到0
							否则就每隔30毫秒向上滚动1px*/
							if(box.scrollTop >= parent.offsetHeight) {
								box.scrollTop = 0;
							} else {
								box.scrollTop++;
							}
							/*判断滚动的距离刚好为一条公告的高度时停掉定时器，
							隔1s之后重新启动定时器即可实现公告滚动停留效果 */
							if(box.scrollTop % box.offsetHeight == 0) {
								clearInterval(timer)
								setTimeout(() => {
									timer = setInterval(autoScrollLine, 30)
								}, 1000)
							}
						}
						$('#advicesize').html(res.length);
					}

					$("#advicestatus").click(function() {
						layer.open({
							type: 2,
							title: '公告动态',
							area: ['700px', '300px'],
							content: 'mynotice.html'
						})
					})
				})
				//公告动态--end

				//修改密码
				form.on('submit(editPsw)', function(data) {
					var newPswAgain = $("#newPswAgain").val();
					var newPsw = $("#newPsw").val();
					var oldPsw = $("#oldPsw").val();
					if(newPsw == newPswAgain) {
						$.post(globalData.server + "user/updatePassWord?token=" + globalData.getToken(), {
							"loginName": globalData.getCurUName(),
							"password": newPsw,
							"oldPsw": oldPsw,
						}, function(res) {
							if(res.code == 0) {
								layer.msg(res.msg, {
									icon: 1,
									time: 2000,
								});
								window.location.href = "login.html";
							} else if(res.code == 2) {
								layer.msg(res.msg, {
									icon: 7,
									time: 2000
								});
							} else {
								layer.msg(res.msg, {
									icon: 2,
									time: 2000
								});
							}
						}, "json")
					} else {
						layer.msg("确认密码与新密码不一致，请检查后再次输入", {
							icon: 7,
							time: 2000
						});
					}
				}) //修改密码--end

				//员工请假添加提交的 监听
				form.on('submit(qingjia)', function(data) {
					$.post(globalData.server + "qingjia/addQingjia?token=" + globalData.getToken(), {
						"userId": globalData.getCurUid(),
						"userName": globalData.getCurUName(),
						"reason": $("input[name='reason']").val(),
						"startTime": $("input[name='startTime']").val(),
						"endTime": $("input[name='endTime']").val(),
						"remark": $("input[name='remark']").val()
					}, function(res) {
						if(res.code == 0) {
							layer.msg(res.msg, {
								icon: 1,
								time: 2000
							}, function() {
								layer.closeAll(); //关闭所有的窗口
								table.reload('demo', {}); //表格重载
								window.location.reload(); //刷新页面
							});
						} else {
							layer.msg(res.msg, {
								icon: 7,
								time: 2000
							}, function() {
								layer.closeAll(); //关闭所有的窗口
								table.reload('demo', {}); //表格重载
							});
						}
					}, "json")
				}) //员工请假添加提交的 监听--end

				//定时消息刷新 
				acitve.getXiaoXiInfo();
				setInterval(function() {
					acitve.getXiaoXiInfo();
				}, 10000); //10秒
				//定时消息刷新 --end

				//修改头像
				$("#userimg").attr("src", globalData.getuserUrl());

				$("#updateu").click(function() {
					console.log(globalData.getuserUrl())
					$("#imgShowUpdate").attr("src", globalData.getuserUrl());
					layer.open({
						type: 1,
						area: ['430px', '320px'],
						content: $("#xiugaiimg")
					})
				})
				//图片上传的代码
				upload.render({
					elem: '#pictureFileUpdate', //指定选择文件的容器
					url: globalData.server + 'fore/imgUpload?token=' + globalData.getToken(), //服务端的地址
					method: 'post', // 类型
					done: function(res, index, upload) {
						console.log(res);
						if(res.code == 0) {
							var imgUrl = JSON.parse(res.data);
							console.log(imgUrl.src);
							$("#imgShowUpdate").attr("src", imgUrl.src);
							$("#imgUrlUpdate").val(imgUrl.src);
						}
					}
				});
				$("#subImgBtn").click(function(data) {
					console.log("aaaaa");
					$.post(globalData.server + "user/updateUserHp?token=" + globalData.getToken(), {
						id: globalData.getCurUid(),
						imgurl: $("#imgUrlUpdate").val()
					}, function(res) {
						if(res.code == 0) {
							globalData.setuserUrl($("#imgUrlUpdate").val());
							layer.msg(res.msg, {
								icon: 1,
								time: 2000
							}, function() {
								layer.closeAll();
								window.location.reload();
							})
						} else {
							layer.msg(res.msg, {
								icon: 7,
								time: 2000
							}, function() {
								layer.closeAll();
								window.location.reload();
							})
						}

					}, "json")
				})
				//修改头像--end

			});
		</script>
	</body>

</html>